<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/10/16 0016
 * Time: 16:20
 */
namespace app\wechat\controller;

use app\index\controller\Base;
use EasyWeChat\Foundation\Application;

class Wechat extends Base {

    protected $options=[
        /**
         * Debug 模式，bool 值：true/false
         *
         * 当值为 false 时，所有的日志都不会记录
         */
        'debug'  => true,
        /**
         * 账号基本信息，请从微信公众平台/开放平台获取
         */
        'app_id' => 'wxafd2764dfa704c60',
        'secret' => '70c99a37bf45150bcb62399b854bc749',
        'token'  => 'easywechat',


        'log' => [
            'level'      => 'debug',
            'permission' => 0777,
            'file'       => './data/runtime/temp/easywechat.log',
        ]
    ];

    public function __construct()
    {

    }

    public $app;
    public function init(){
        $config=config('we_options');
        if(!empty($config)) $this->options=array_merge($this->options,$config);
        $this->app = new Application($this->options);
        var_dump($this->app);
//        $app = Factory::officialAccount($this->options);
//        $server = $app->server;
//        $user = $app->user;
//
//        $server->push(function($message) use ($user) {
//            $fromUser = $user->get($message['FromUserName']);
//
//            return "{$fromUser->nickname} 您好！欢迎关注 overtrue!";
//        });
//
//        $server->serve()->send();
    }
}